//
//  CZBaseTableViewController.swift
//  CZweibo
//
//  Created by mac on 16/3/21.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class CZBaseTableViewController: UITableViewController {

    /// 用户是否登录
    var userLogin = false
    
    override func loadView() {
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    /// 设置访客视图
    func setupVisitorView() {
        view = visltorView
        
        //设置访客视图代理
        visltorView.delegate = self
        /**
        *  访客视图的界面
        */
        if (self is CZHomeController) {
           // 转轮动画 方法
            visltorView.startRotation()
                    }
        else if (self is CZMessageController) {
            visltorView.setupVisitor("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }
        else if (self is CZDiscoverController) {
            visltorView.setupVisitor("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }
        else if (self is CZProfileController) {
            visltorView.setupVisitor("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "CZVisltorViewDidClickRegisterButton")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "CZVisltorViewDidclickLoginButton")
        
    }
  
    // MARK: - 懒加载
    ///自定义访客视图
    lazy var visltorView:CZVisltorView = CZVisltorView()
}

//MARK: - extension协议
extension CZBaseTableViewController : CZVisltorViewDelegate {
    
    //调用代理方法
    func CZVisltorViewDidClickRegisterButton() {
        let networkToll = CZNetworkTool.sharedInstance
        print("networkToll:\(networkToll)")
        
        
    }
    
    func CZVisltorViewDidclickLoginButton() {
        let networkToll = CZNetworkTool.sharedInstance
        print("networkToll:\(networkToll)")
        
    }

}
